{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号：\n",
    "+ 姓名  文华虎\n",
    "+ 学号  0165180"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "class poor_family(object):\n",
    "    def __initial__(self,x1,x2,x3,x4):\n",
    "        self.education=x1\n",
    "        self.housing=x2\n",
    "        self.drinking_safety=x3\n",
    "        self.protein=x4\n",
    "                    \n",
    "    def jiaoyu(self,xuefei):\n",
    "        if xuefei>300:\n",
    "            self.education=True\n",
    "        else:\n",
    "            self.education=False\n",
    "    \n",
    "    def zhufang(self,huanjing):\n",
    "        if huanjing>3:\n",
    "            self.housing=True\n",
    "        else:\n",
    "            self.housing=False\n",
    "            \n",
    "    def yinshui(self,shuizhi):\n",
    "        if shuizhi>3:\n",
    "            self.drinking_safety=True\n",
    "        else:\n",
    "            self.drinking_safety=False\n",
    "            \n",
    "    def shiwu(self,sheru):\n",
    "        if sheru>3:\n",
    "            self.protein=True\n",
    "        else:\n",
    "            self.protein=False\n",
    "\n",
    "def evalution(self):\n",
    "        sum=0\n",
    "        if self.education==False:\n",
    "            sum=sum+1\n",
    "        if self.housing==False:\n",
    "            sum=sum+1\n",
    "        if self.drinking_safety==False:\n",
    "            sum=sum+1\n",
    "        if self.protein==False:\n",
    "            sum=sum+1\n",
    "        if sum>2:\n",
    "            print('是贫困户')\n",
    "            if self.education==False:\n",
    "                print('教育水平需要扶持')\n",
    "            if self.housing==False:\n",
    "                print('住房水平需要扶持')\n",
    "            if self.drinking_safety==False:\n",
    "                print('饮水安全需要扶持')\n",
    "            if self.protein==False:\n",
    "                print('肉蛋奶豆需要扶持')\n",
    "        else:\n",
    "            print('不是贫困户')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "家庭1：\n",
      "是贫困户\n",
      "教育水平需要扶持\n",
      "住房水平需要扶持\n",
      "饮水安全需要扶持\n",
      "肉蛋奶豆需要扶持\n",
      "家庭2：\n",
      "不是贫困户\n",
      "家庭3：\n",
      "不是贫困户\n"
     ]
    }
   ],
   "source": [
    "jiating1=poor_family()\n",
    "jiating1.jiaoyu(xuefei=300)\n",
    "jiating1.zhufang(huanjing=2)\n",
    "jiating1.yinshui(shuizhi=2)\n",
    "jiating1.shiwu(sheru=2)\n",
    "print('家庭1：')\n",
    "evalution(jiating1)\n",
    "\n",
    "jiating2=poor_family()\n",
    "jiating2.jiaoyu(xuefei=400)\n",
    "jiating2.zhufang(huanjing=4)\n",
    "jiating2.yinshui(shuizhi=3)\n",
    "jiating2.shiwu(sheru=4)\n",
    "print('家庭2：')\n",
    "evalution(jiating2)\n",
    "\n",
    "jiating3=poor_family()\n",
    "jiating3.jiaoyu(xuefei=500)\n",
    "jiating3.zhufang(huanjing=4)\n",
    "jiating3.yinshui(shuizhi=2)\n",
    "jiating3.shiwu(sheru=2)\n",
    "print('家庭3：')\n",
    "evalution(jiating3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Jack BMI可能偏大\n",
      "Rose 体重正常\n",
      "Richel 体重正常\n"
     ]
    }
   ],
   "source": [
    "class students(object):\n",
    "    def _init_(self,name,x2,x3):\n",
    "        self.name=name\n",
    "        self.grade=x2\n",
    "        self.slumber=x3\n",
    "    \n",
    "def student(self):\n",
    "        if self.grade>90 and self.slumber<6:\n",
    "            print(\"%s BMI可能偏大\" %self.name)\n",
    "        else:\n",
    "            print(\"%s 体重正常\" %self.name)\n",
    "    \n",
    "student_a=students()\n",
    "student_a.name='Jack'\n",
    "student_a.grade=91\n",
    "student_a.slumber=5\n",
    "student(student_a)\n",
    "\n",
    "student_b=students()\n",
    "student_b.name='Rose'\n",
    "student_b.grade=88\n",
    "student_b.slumber=5\n",
    "student(student_b)\n",
    "\n",
    "student_c=students()\n",
    "student_c.name='Richel'\n",
    "student_c.grade=88\n",
    "student_c.slumber=7\n",
    "student(student_c)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "class students(object):\n",
    "    def _init_(self,name,x2,x3):\n",
    "        self.name=name\n",
    "        self.grade=x2\n",
    "        self.slumber=x3\n",
    "    \n",
    "def student(self):\n",
    "        if self.grade>90 and self.slumber<6:\n",
    "            print(\"%s BMI可能偏大\" %self.name)\n",
    "        else:\n",
    "            print(\"%s 体重正常\" %self.name)\n",
    "\n",
    "class running_club(object):\n",
    "    def _ini(self,running):\n",
    "        self.running=running\n",
    "        \n",
    "def run(self):\n",
    "    if self.grade>90 and self.slumber<6 and self.running>30:\n",
    "        print('%s 体重趋向正常'%self.name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Jack BMI可能偏大\n",
      "Jack 体重趋向正常\n",
      "Rose 体重正常\n",
      "Richel 体重正常\n"
     ]
    }
   ],
   "source": [
    "student_a=students()\n",
    "student_a=running_club()\n",
    "student_a.name='Jack'\n",
    "student_a.grade=91\n",
    "student_a.slumber=5\n",
    "student(student_a)\n",
    "student_a.running=31\n",
    "run(student_a)\n",
    "\n",
    "student_b=students()\n",
    "student_b=running_club()\n",
    "student_b.name='Rose'\n",
    "student_b.grade=88\n",
    "student_b.slumber=5\n",
    "student(student_b)\n",
    "student_b.running=29\n",
    "run(student_b)\n",
    "\n",
    "student_a=students()\n",
    "student_a=running_club()\n",
    "student_a.name='Richel'\n",
    "student_a.grade=95\n",
    "student_a.slumber=8\n",
    "student(student_a)\n",
    "student_a.running=33\n",
    "run(student_a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
